package com.alice.consumer.controller;

import com.alice.consumer.client.ItemsClient;
import com.alice.consumer.pojo.ItemForm;
import com.alice.consumer.pojo.ItemVo;
import com.alice.consumer.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by caoxuel on 2020/9/23 13:25
 */
@RestController
@RequestMapping("itemClient")
@CrossOrigin
public class ItemsFeignController {
    @Autowired
    private ItemsClient itemClient;

    @GetMapping("/{id}")
    public Result queryById(@PathVariable Integer id){
        return itemClient.queryById(id);
    }

    @GetMapping("list")
    public Result queryAllItem(){
        return itemClient.queryAllItem();
    }

    @DeleteMapping("{id}")
    public Result deleteItem(@PathVariable Integer id){
        return itemClient.deleteItem(id);
    }

    @PostMapping("add")
    public Result addItem(@RequestBody ItemForm item){
        return itemClient.addItem(item);
    }

    @PostMapping("updateItem")
    public Result updateItem(@RequestBody ItemForm item){
        return itemClient.updateItem(item);
    }

    @PostMapping("{page}/{limit}")
    public Result queryListPage(@PathVariable Integer page,
                                @PathVariable Integer limit,
                                @RequestBody(required = false) ItemVo item){
        return itemClient.queryListPage(page,limit,item);
    }
}
